<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="css/feedback.css" />
		<link rel="stylesheet" type="text/css" href="css/iconfont3.css">
		<link rel="stylesheet" type="text/css" href="css/iconfont4.css">
		<link rel="stylesheet" type="text/css" href="css/mui.picker.min.css" />
		<link href="css/mui.poppicker.css" rel="stylesheet" />
		
		<style>
		
			/* 主界面css*/
			html,
			body {
				background-color: #efeff4;
			}
			.mui-views,
			.mui-view,
			.mui-pages,
			.mui-page,
			.mui-page-content {
				position: absolute;
				left: 0;
				right: 0;
				top: 0;
				bottom: 0;
				width: 100%;
				height: 100%;
				background-color: #efeff4;
			}
			.mui-pages {
				top: 46px;
				height: auto;
			}
			.mui-scroll-wrapper,
			.mui-scroll {
				background-color: #efeff4;
			}
			.mui-page.mui-transitioning {
				-webkit-transition: -webkit-transform 300ms ease;
				transition: transform 300ms ease;
			}
			.mui-page-left {
				-webkit-transform: translate3d(0, 0, 0);
				transform: translate3d(0, 0, 0);
			}
			.mui-ios .mui-page-left {
				-webkit-transform: translate3d(-20%, 0, 0);
				transform: translate3d(-20%, 0, 0);
			}
			.mui-navbar {
				position: fixed;
				right: 0;
				left: 0;
				z-index: 10;
				height: 44px;
				background-color: #f7f7f8;
			}
			.mui-navbar .mui-bar {
				position: absolute;
				background: transparent;
				text-align: center;
			}
			.mui-android .mui-navbar-inner.mui-navbar-left {
				opacity: 0;
			}
			.mui-ios .mui-navbar-left .mui-left,
			.mui-ios .mui-navbar-left .mui-center,
			.mui-ios .mui-navbar-left .mui-right {
				opacity: 0;
			}
			.mui-navbar .mui-btn-nav {
				-webkit-transition: none;
				transition: none;
				-webkit-transition-duration: .0s;
				transition-duration: .0s;
			}
			.mui-navbar .mui-bar .mui-title {
				display: inline-block;
				width: auto;
			}
			.mui-page-shadow {
				position: absolute;
				right: 100%;
				top: 0;
				width: 16px;
				height: 100%;
				z-index: -1;
				content: '';
			}
			.mui-page-shadow {
				background: -webkit-linear-gradient(left, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, .01) 50%, rgba(0, 0, 0, .2) 100%);
				background: linear-gradient(to right, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 10%, rgba(0, 0, 0, .01) 50%, rgba(0, 0, 0, .2) 100%);
			}
			.mui-navbar-inner.mui-transitioning,
			.mui-navbar-inner .mui-transitioning {
				-webkit-transition: opacity 300ms ease, -webkit-transform 300ms ease;
				transition: opacity 300ms ease, transform 300ms ease;
			}
			.mui-page {
				display: none;
			}
			.mui-pages .mui-page {
				display: block;
			}
			.mui-page .mui-table-view:first-child {
				margin-top: 15px;
			}
			.mui-page .mui-table-view:last-child {
				margin-bottom: 30px;
			}
			.mui-table-view {
				margin-top: 20px;
			}
			
			.mui-table-view span.mui-pull-right {
				color: #999;
			}
			.mui-table-view-divider {
				background-color: #efeff4;
				font-size: 14px;
			}
			.mui-table-view-divider:before,
			.mui-table-view-divider:after {
				height: 0;
			}
			.head {
				height: 40px;
			}
			#head {
				line-height: 40px;
			}
			.head-img {
				width: 40px;
				height: 40px;
			}
			#head-img1 {
				position: absolute;
				bottom: 10px;
				right: 40px;
				width: 40px;
				height: 40px;
			}
			.update {
				font-style: normal;
				color: #999999;
				margin-right: -25px;
				font-size: 15px
			}
			.mui-fullscreen {
				position: fixed;
				z-index: 20;
				background-color: #000;
			}
			.mui-ios .mui-navbar .mui-bar .mui-title {
				position: static;
			}
			/*问题反馈在setting页面单独的css*/
			#feedback .mui-popover{
				position: fixed;
			}
			#feedback .mui-table-view:last-child {
			    margin-bottom: 0px;
			}
			#feedback .mui-table-view:first-child {
			    margin-top: 0px;
			}
			
			/*企业好友css*/
			
			 .oa-contact-cell.mui-table .mui-table-cell {
				padding: 11px 0;
				vertical-align: middle;
			}
			
			.oa-contact-cell {
				position: relative;
				margin: -11px 0;
			}
	
			.oa-contact-avatar {
				width: 75px;
			}
			.oa-contact-avatar img {
				border-radius: 50%;
			}
			.oa-contact-content {
				width: 100%;
			}
			.oa-contact-name {
				margin-right: 20px;
			}
			.oa-contact-name, oa-contact-position {
				float: left;
			}
			/*选择时间和地址的位置*/
				.ui-alert {
			
				padding: 9px 30px;
				font-size: 16px;
			}
			
		</style>
		<link rel="stylesheet" type="text/css" href="css/feedback.css" />
		<link rel="stylesheet" type="text/css" href="css/iconfont.css">
		<link rel="stylesheet" type="text/css" href="css/iconfont2.css">
	</head>

	<body class="mui-fullscreen" onload="getDepartList();checkJob()">
		<!--页面主结构开始-->
		<div id="app" class="mui-views">
			<div class="mui-view">
				<div class="mui-navbar">
				</div>
				<div class="mui-pages">
				</div>
			</div>
		</div>
		<!--页面主结构结束-->
		<!--单页面开始-->
		<div id="setting" class="mui-page" style="top: -10px;">
			<!--页面标题栏开始-->
			<div class="mui-navbar-inner mui-bar mui-bar-nav">
				<button type="button" class="mui-left mui-btn  mui-btn-link mui-btn-nav mui-pull-left" onclick="javascript:window.location.href='qiye-detail.html' ">
					<span class="mui-icon mui-icon-left-nav"></span>
				</button>
				<h1 class="mui-center mui-title">部门列表</h1>
				<button type="button" class="mui-right mui-btn  mui-btn-link mui-btn-nav mui-pull-right">
					<a href="scNewDepart.html" class="mui-icon mui-icon-plusempty"></a>
				</button>
			</div>
		
			<div class="mui-page-content">
				<div class="mui-scroll-wrapper">
					<div class="mui-scroll">
						<ul id="DepartList" class="mui-table-view mui-table-view-chevron">
					
						</ul>	
					</div>
				</div>
			</div>
		</div>
		<script>
			var id=localStorage.getItem("employeeid");
			var eJob="";
			function checkJob(){
				var network = true;
				if(mui.os.plus) {
					mui.plusReady(function() {
						if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
							network = false;
						}
					});
				}
				if(network) {
						console.log('网络正常,正在发送请求...');
							 mui.ajax({
                                    url:"http://113.71.26.27:8080/tpl/phone/findEmp",
                                    async:true,
     								type:'post',
     								dataType:"json", 
     								data:{
     									id:id
     								},
     							 	success:function(data){
     							 		eJob=data.job;
     							 		
     								}
     						});
					} else {
						mui.toast("当前网络不给力，请稍后再试...");
				}

			}
			
		
		</script>
		
		<script>
			var id=localStorage.getItem("employeeid");
			function getDepartList(){
				var network = true;
				if(mui.os.plus) {
					mui.plusReady(function() {
						if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
							network = false;
						}
					});
				}
				if(network) {
						console.log('网络正常,正在发送请求...');
							 mui.ajax({
                                    url:'http://113.71.26.27:8080/tpl/phone/getAllDepart',
                                    async:true,
     								type:'post',
     								data:{
     									conpanyid:id
     								},
     							 	success:function(data){
     							 		var depart='';
     							 		var message='';
     							 		var updateMessage='';    									
     							 		for(var i=0;i<data.length;i++){
       										depart+="<li class='mui-table-view-cell'>"+
														"<a href='#data"+data[i].id+"' class=''>"+
														"<span class='mui-tab-label mui-slider-handle mui-icon mui-icon-flag' style='font-size: 18px;'>"+data[i].name+"</span></a>"+
														//if(eJob!="员工"){
                   			  						    	"<button  onclick='sure("+data[i].id+")' style='float:right'>删除</button>"+
                   			  						   	//}
													"</li>"
											
											message+="<div id='data"+data[i].id+"' class='mui-page'>"+
														"<div class='mui-navbar-inner mui-bar mui-bar-nav'>"+
															"<button type='button' class='mui-left mui-action-back mui-btn  mui-btn-link mui-btn-nav mui-pull-left'>"+
															"<span class='mui-icon mui-icon-left-nav'></span>"+
															"</button>"+
															"<h1 class='mui-title'>部门详细信息 </h1>"+
															"<button type='button' class='mui-right  mui-btn  mui-btn-link mui-btn-nav mui-pull-right'>"+
															"<a href='#update"+data[i].id+"' class='mui-btn-primary'>修改</a>"+
															"</button>"+
														"</div>"+
														"<div class='mui-page-content'>"+
			  												"<div class='mui-scroll-wrapper'>"+
			   													"<div class='mui-scroll'>"+
																	"<div id='Departform' class='mui-content-padded' style='margin: 0px;'>"+			
																	"<form class='mui-input-group'>"+
																		"<div class='mui-input-row'>"+
																			"<label>部门名称</label>"+
																			"<input type='text' class='mui-input-clear' placeholder='"+data[i].name+"' readonly='readonly'>"+
																		"</div>"+
																		"<div class='mui-input-row'>"+
																			"<label>部门负责人</label>"+
																			"<input type='text' class='mui-input-clear' placeholder='"+data[i].manager+"' readonly='readonly'>"+
																		"</div>"+			
																		"<div class='mui-input-row' style='height:100px'>"+
																			"<label>部门描述</label>"+
																			"<textarea  rows='5' placeholder='"+data[i].describer+"'  readonly='readonly'></textarea>"+
																		"</div>"+
																	"</form>"+
																	"</div>"+	
			   													"</div>"+
			  												"</div>"+
														"</div>"+
													"</div>"
													
											updateMessage+="<div id='update"+data[i].id+"' class='mui-page'>"+
														"<div class='mui-navbar-inner mui-bar mui-bar-nav'>"+
															"<button type='button' class='mui-left mui-action-back mui-btn  mui-btn-link mui-btn-nav mui-pull-left'>"+
															"<span class='mui-icon mui-icon-left-nav'></span>"+
															"</button>"+
															"<h1 class='mui-title'>部门详细信息 </h1>"+
															"<button type='button' class='mui-right  mui-btn  mui-btn-link mui-btn-nav mui-pull-right'>"+
															"<a onclick='updateForm("+i+")' class='mui-btn-primary'>提交</a>"+
															"</button>"+
														"</div>"+
														"<div class='mui-page-content'>"+
			  												"<div class='mui-scroll-wrapper'>"+
			   													"<div class='mui-scroll'>"+
																	"<div class='mui-content-padded' style='margin: 0px;'>"+			
																	"<form id='Departform' class='mui-input-group'>"+
																		"<div class='mui-input-row'>"+
																			"<input id='mDId"+i+"' type='hidden' class='mui-input-clear' value='"+data[i].id+"'>"+
																			"<label>部门名称</label>"+
																			"<input id='mDname"+i+"' type='text' class='mui-input-clear' value='"+data[i].name+"' >"+
																		"</div>"+
																		"<div class='mui-input-row'>"+
																			"<label>部门负责人</label>"+
																			"<input id='mDmanager"+i+"' type='text' class='mui-input-clear' value='"+data[i].manager+"' >"+
																		"</div>"+			
																		"<div class='mui-input-row' style='height:100px'>"+
																			"<label>部门描述</label>"+
																			"<textarea id='mDdescriber"+i+"' rows='5' placeholder='"+data[i].describer+"'>"+data[i].describer+"</textarea>"+
																		"</div>"+
																	"</form>"+
																	"</div>"+	
			   													"</div>"+
			  												"</div>"+
														"</div>"+
													"</div>";
										
										
       									}
       									$('#DepartList').append(depart);
       									$("#departmessage").append(message);
       									$("#updateDepart").append(updateMessage);
   
       									
     								}
     							})
					} else {
						mui.toast("当前网络不给力，请稍后再试...");
				}

			}
			function sure(id){
				var btnArray = ['否', '是'];
						mui.confirm('是否删除该部门？', '', btnArray, function(e) {
							if(e.index == 1) {
								delDepart(id);
							}
						});
			}
			function delDepart(id){
				var network = true;
				if(mui.os.plus) {
					mui.plusReady(function() {
						if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
							network = false;
						}
					});
				}
				if(network) {
						console.log('网络正常,正在发送请求...');
						console.log(eJob);
						if(eJob!="普通员工"){
							 mui.ajax({
                                    url:'http://113.71.26.27:8080/tpl/phone/delDepart?id='+id,
                                    async:true,
     								type:'post',
     								data:{},
     							 	success:function(data){
     							 		if(data=="ok" || data.equals("ok")){
     							 			window.location.href= "bumen-list.html";
                			    			mui.toast("删除成功！");
                			    			
                			    		}else{
                			    			mui.toast("删除失败，请重新删除！");
                			    		}
     								}
     							});
     					}else{
     						mui.toast("权限不足！");
     					}
     				
					} else {
						mui.toast("当前网络不给力，请稍后再试...");
				}
				
			}
			
					
			
			
			
			function updateForm(i){
				var mid=document.getElementById("mDId"+i).value;
				var mname=document.getElementById("mDname"+i).value;
				var manager=document.getElementById("mDmanager"+i).value;
			    var mdescriber=document.getElementById("mDdescriber"+i).value;
				var network = true;
				if(mui.os.plus) {
					mui.plusReady(function() {
						if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
							network = false;
						}
					});
				}
				if(network) {
					console.log('网络正常,正在发送请求...');
					if(eJob!="普通员工"){
					  if(mname!="" && manager!="" && mdescriber!=""){
						mui.ajax({
                 				async:true,
     							type:'post',
                				url:'http://113.71.26.27:8080/tpl/phone/updateDepart',
                				data:{
                					id:mid,
                					name:mname,
                					describer:mdescriber,
                					manager:manager,
                				},// 你的formid
                			    success: function(data){
                			    	if(data=="ok"){
                			    		window.location.href= "bumen-list.html";
                			    		mui.toast("更改成功！");
                			    	}else{
                			    		mui.toast("更改失败，请重新更改！");
                			    	}
                			    }
                			  });
                	  }else{
                	  	mui.toast("请输入完整信息！");
                	  }
                	}else{
                		mui.toast("权限不足！");
                	}
				}else {
					mui.toast("当前网络不给力，请稍后再试...");
				}
			}
			
		</script>
		
	
		<div id="departmessage">
			<!--      部门详细信息           -->
		</div>
		
		<div id="updateDepart">
			<!--      修改部门信息           -->
		</div>

	</body>
	<script src="js/mui.min.js "></script>
	<script src="js/mui.view.js "></script>
	
	<script type="text/javascript" src="jquery.js"></script> 
	<script type="text/javascript" src="jquery.qrcode.min.js"></script> 
	<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
	<script>
		mui.init({
  			gestureConfig:{
    		longtap: true, //默认为false
    		release:true
   			}
		});
		//mui.init();
		//初始化单页view
		var viewApi = mui('#app').view({
			defaultPage: '#setting'
		});
		//初始化单页的区域滚动
		mui('.mui-scroll-wrapper').scroll();
		//分享操作

		var view = viewApi.view;
		(function($) {
			//处理view的后退与webview后退
			var oldBack = $.back;
			$.back = function() {
				if (viewApi.canBack()) { //如果view可以后退，则执行view的后退
					viewApi.back();
				} else { //执行webview后退
					//oldBack();
					window.location.href = "qiye-detail.html";
				}
			};
			
		})(mui);
	
			
			
		
	</script>
	
</html>